﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for FleetPaymentsDB
/// </summary>
namespace CE.CarInsurance
{
    public class FleetPaymentsDB
    {
        public Int64 Insert(FleetPayments fleetpayments)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMFleetPaymentDetailsInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@PaymentId", fleetpayments.PaymentId);
            _sPara.Add("@QuoteRefNo", fleetpayments.QuoteRefNo);
            _sPara.Add("@FleetCarId", fleetpayments.FleetCarId);
            _sPara.Add("@CompanyId", fleetpayments.CompanyId);
            _sPara.Add("@ProviderCompanyId", fleetpayments.ProviderCompanyId);
            _sPara.Add("@RefCEUserId", fleetpayments.RefCEUserId);
            _sPara.Add("@AgentId", fleetpayments.AgentId);
            _sPara.Add("@AdminId", fleetpayments.AdminId);
            _sPara.Add("@PaymentType", fleetpayments.PaymentType);
            _sPara.Add("@PaymentMode", fleetpayments.PaymentMode);
            _sPara.Add("@PaymentOption", fleetpayments.PaymentOption);
            _sPara.Add("@NoofInstallments", fleetpayments.NoofInstallments);
            _sPara.Add("@PaymentBank", fleetpayments.PaymentBank);
            _sPara.Add("@CollectedAmount", fleetpayments.CollectedAmount);
            _sPara.Add("@AmountwithInterest", fleetpayments.AmountwithInterest);
            _sPara.Add("@TransactionType", fleetpayments.TransactionType);
            _sPara.Add("@ApproveType", fleetpayments.ApproveType);
            _sPara.Add("@PaymentRefNo", fleetpayments.PaymentRefNo);
            _sPara.Add("@CardHolder", fleetpayments.CardHolder);
            _sPara.Add("@IssuingBank", fleetpayments.IssuingBank);
            _sPara.Add("@CreditCardNo", fleetpayments.CreditCardNo);
            _sPara.Add("@CardExpiryMonth", fleetpayments.CardExpiryMonth);
            _sPara.Add("@CardExpiryYear", fleetpayments.CardExpiryYear);
            _sPara.Add("@CardType", fleetpayments.CardType);
            _sPara.Add("@CVV", fleetpayments.CVV);
            _sPara.Add("@IsOnlinePayment", fleetpayments.IsOnlinePayment);
            _sPara.Add("@Status", fleetpayments.Status);
            _sPara.Add("@NoOfDays", fleetpayments.NoOfDays);
            _sPara.Add("@UserTypeId", fleetpayments.UserTypeId);
            _sPara.Add("@Info2", fleetpayments.Info2);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetPayments(Int64 FleetCarId, Int16 IsOnlinePayment)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRMPaymentsDetailsSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@FleetCarId", FleetCarId);
            _spara.Add("@IsOnlinePayment", IsOnlinePayment);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetPayments(Int64 FleetCarId)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRMPaymentsDetailsSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@FleetCarId", FleetCarId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

    }
}